package chap4_3复制java文件案例;

import java.io.*;

/**
 * @author https://gitee.com/W_Jun
 * @date 2021-12-16 21:27
 * @Description
 */
public class CopyJavaDemo {
    public static void main(String[] args) throws IOException {
        /*
        //根据数据源创建字符输入流对象
        BufferedReader br = new BufferedReader(new FileReader("chapter04-特殊操作流\\src\\chap4_2打印流\\PrintStreamDemo.java"));
        //根据目的地创建字符输出流对象
        BufferedWriter bw = new BufferedWriter(new FileWriter("chapter04-特殊操作流\\Copy.java"));
        //读写数据，复制文件
        String line;
        while ((line = br.readLine()) != null) {
            bw.write(line);
            bw.newLine();
            bw.flush();
        }
        //释放资源
        bw.close();
        br.close();
        */
        //根据数据源创建字符输入流对象
        BufferedReader br = new BufferedReader(new FileReader("chapter04-特殊操作流\\src\\chap4_2打印流\\PrintStreamDemo.java"));
        //根据目的地创建字符输出流对象
        PrintWriter pw = new PrintWriter(new FileWriter("chapter04-特殊操作流\\\\Copy.java"), true);
        //读写数据
        String line;
        while ((line = br.readLine()) != null) {
            pw.println(line);
        }
        pw.close();
        br.close();
    }
}
